package com.dayuanit.mall.bank.payenum;

import com.dayuanit.mall.bank.exception.MallBusException;

public enum PayErrorEnum {
	
	ALREADY_PAY(200001, "订单已支付"), PAY_ING(200002, "订单支付中"), 
	PAY_INVALID(200003, "订单失效"), SIGN_IS_EMPTY(200004, "签名不可为空"), PARAM_IS_EMPTY(200005, "必填参数不可为空"),
	PARAM_VALUE_ERROR(200006, "参数错误"), SIGN_VALUE_ERROR(200007, "签名错误"), PAY_ORDER_CREATE_ERROR(200008, "订单创建失败"),
	PAY_PASSWORD_ERROR(200009, "密码错误"), PAY_ORDER_INVALID(200010, "非法订单"), PAY_ORDER_PAY_FAILED(200011, "订单支付失败"),
	PAY_ORDER_UNEXIST(200012, "商户订单不存在");
	
	private int code;
	private String desc;
	
	private PayErrorEnum(int errorCode, String errorDesc) {
		this.code = errorCode;
		this.desc = errorDesc;
	}
	
	public PayErrorEnum getPayStatus(int errorCode) {
		
		for (PayErrorEnum ps : PayErrorEnum.values()) {
			if (ps.getCode() == errorCode) {
				return ps;
			}
		}
		
		throw new MallBusException("无效的错误码");
	}

	public int getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}
	
}
